<template>

</template>
<script>
import { Toast } from 'mint-ui'
export default {
  data () {
    return {
      checkedNames: [],
      Width: 0,
      hasShow: false,
      number: 1,
      nowItemContainer: null,
      cartsList: [{
        li: 1,
        number: 1,
        kucun: 9,
        checked: false
      }, {
        li: 2,
        number: 2,
        kucun: 2,
        checked: false
      }, {
        li: 2,
        number: 3,
        kucun: 9,
        checked: true
      }, {
        li: 4,
        number: 1,
        kucun: 55,
        checked: false
      }]
    }
  },
  created () {
  },
  mounted () {
  },
  computed: {
  },
  methods: {
    // 单选
    check (item) {
      item.checked = !item.checked
    },
    // 商品数量输入失去焦点判断
    countChange (item) {
      if (isNaN(item.number)) {
        Toast('商品的数量不能为非数字');
        item.number = 1;
        return false
      }
      if (!item.number) {
        Toast('商品的数量不能为空');
        item.number = 1;
        return false
      }
      if (item.number <= 0) {
        Toast('商品的数量不能为0');
        item.number = 1;
        return false
      }
      if (item.number > item.kucun) {
        Toast('最多只可以购买99件该商品');
        item.number = 99;
        return false
      }
    },
    changeChecked (cartsList) {
      cartsList.checked !== cartsList.checked;
    },
    // ++ 数量
    addNum (item) {
      console.log('add')
      if (item.number >= item.kucun) {
        Toast('超过最大数量')
        return false
      }
      item.number ++
    },
    // -- 数量
    reduceNum (item) {
      if (item.number <= 1) {
        Toast('最少购买一件')
        return false
      }
      item.number --
    }
  }
}
</script>
<style scoped>
.list{background: #fff;}
.item {
  height: 4rem;
  position: relative;
  overflow: hidden;
}

.item-container {
  display: flex;
  align-items: center;
  height: 100%;
  transition: all .2s ease-in;
}

.right-wrap {
  display: flex;
  align-items: center;
  flex: 1;
}

.desc-wrap {
  flex: 1;
}

.line1 {
  line-height: .42667rem;
  font-size: .37333rem;
  margin-bottom: .13333rem;
}

.line2 {
  font-size: .32rem;
  line-height: .37333rem;
  margin-bottom: .10667rem;
  color: #666;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.line3 {
  font-size: .37333rem;
  line-height: .42667rem;
}

.checkbox {
  padding: 0 .2846rem;
}

.img-wrap {
  margin-right: .26667rem;
}

.img-wrap img {
  width: 2.5rem;
  height: 2.5rem;
}

.total-num {
  align-items: flex-start;
  font-size: 16px;
  margin-right: 8px;
}


/*del*/

.del-box {
  position: absolute;
  top: 0;
  left: 100%;
  width: 1.86667rem;
  background-color: #e83a3a;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.u-icon-trash {
  display: block;
  width: .54667rem;
  height: .56rem;
  background-size: cover;
}


/*- + 不可点击*/
.m-selnum.dlr {
    background-position: 0 -2.08rem;
}
/*+ 可以点击*/
.m-selnum.dl {
    background-position: 0 -1.04rem;
}
/*- + 都可以点击*/
.m-selnum {
    background-position: 0 -8.29333rem;
    width: 4.13333rem;
    height: .93333rem;
}
.m-selnum.allactive{
    background-position: 0 -8.29333rem;  
}

.m-selnum, .m-selnum-1 {
    display: inline-block;
    background-image: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/selnum-s2aa5e4fbe0-14d469f19a.png);
    background-repeat: no-repeat;
    background-size: 4.12rem 9.2rem;
    vertical-align: middle;
}
.m-selnum .less, .m-selnum .more {
    width: 1.2rem;
}
.m-selnum .less, .m-selnum .more, .m-selnum .textWrap {
    position: relative;
    float: left;
    height: .88rem;
}
.m-selnum .less, .m-selnum .more, .m-selnum .textWrap, .m-selnum input {
    border: none;
    background-color: transparent;
}
.m-selnum .textWrap {
    position: relative;
    width: 1.72rem;
    text-align: center;
    font-size: .32rem;
    line-height: .88rem;
}
.m-selnum .less, .m-selnum .more, .m-selnum .textWrap {
    position: relative;
    float: left;
    height: .88rem;
}
.m-selnum .less, .m-selnum .more, .m-selnum .textWrap, .m-selnum input {
    border: none;
    background-color: transparent;
}
.m-selnum .textWrap input {
    position: relative;
    z-index: 1;
    font-size: .32rem;
}
.m-selnum input {
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    text-align: center;
    color: #333;
}
.m-selnum .less, .m-selnum .more {
    width: 1.2rem;
}
</style>
